﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Drawing;
using Xlsx.ComponentModel;
using Xlsx.ComponentModel.Enums;

namespace Xslx.DataBinder.Tests.ComponentModel
{
    [TestClass]
    public class XlsxSkinTest
    {
        [TestMethod]
        public void TestEquals()
        {
            var xlsx = new XlsxSkin
                {
                BorderColor = Color.Transparent,
                BorderStyle = XlsxBorderStyle.None,
                FillColor = Color.Transparent,
                FontColor = Color.Black,
                FontSize = 10,
                HasBorder = false,
                IsBold = false,
                IsItalic = false,
                IsUnderline = false
            };

            var xlsxValid = new XlsxSkin
                {
                BorderColor = Color.Transparent,
                BorderStyle = XlsxBorderStyle.None,
                FillColor = Color.Transparent,
                FontColor = Color.Black,
                FontSize = 10,
                HasBorder = false,
                IsBold = false,
                IsItalic = false,
                IsUnderline = false
            };

            var xlsxFailed = new XlsxSkin
                {
                BorderColor = Color.Transparent,
                BorderStyle = XlsxBorderStyle.Medium,
                FillColor = Color.Transparent,
                FontColor = Color.Black,
                FontSize = 10,
                HasBorder = false,
                IsBold = false,
                IsItalic = false,
                IsUnderline = false
            };

            var objFailed = new object();

            Assert.IsTrue(xlsx.Equals(xlsxValid));
            Assert.IsFalse(xlsx.Equals(xlsxFailed));
            Assert.IsFalse(xlsx.Equals(null));
            Assert.IsFalse(xlsx.Equals(objFailed));
        }

        [TestMethod]
        public void TestDefault()
        {
            var expected = new XlsxSkin
                {
                BorderColor = Color.Transparent,
                BorderStyle = XlsxBorderStyle.None,
                FillColor = Color.Transparent,
                FontColor = Color.Black,
                FontSize = 10,
                HasBorder = false,
                IsBold = false,
                IsItalic = false,
                IsUnderline = false
            };

            var actual = XlsxSkin.Default;

            Assert.AreEqual(expected.BorderColor.A, actual.BorderColor.A);
            Assert.AreEqual(expected.BorderColor.R, actual.BorderColor.R);
            Assert.AreEqual(expected.BorderColor.G, actual.BorderColor.G);
            Assert.AreEqual(expected.BorderColor.B, actual.BorderColor.B);
            Assert.AreEqual(expected.BorderStyle, actual.BorderStyle);
            Assert.AreEqual(expected.FillColor.A, actual.FillColor.A);
            Assert.AreEqual(expected.FillColor.R, actual.FillColor.R);
            Assert.AreEqual(expected.FillColor.G, actual.FillColor.G);
            Assert.AreEqual(expected.FillColor.B, actual.FillColor.B);
            Assert.AreEqual(expected.FontColor.A, actual.FontColor.A);
            Assert.AreEqual(expected.FontColor.R, actual.FontColor.R);
            Assert.AreEqual(expected.FontColor.G, actual.FontColor.G);
            Assert.AreEqual(expected.FontColor.B, actual.FontColor.B);
            Assert.AreEqual(expected.FontSize, actual.FontSize);
            Assert.AreEqual(expected.HasBorder, actual.HasBorder);
            Assert.AreEqual(expected.IsBold, actual.IsBold);
            Assert.AreEqual(expected.IsItalic, actual.IsItalic);
            Assert.AreEqual(expected.IsUnderline, actual.IsUnderline);
        }

                [TestMethod]
        public void TestClone()
        {
            var expected = new XlsxSkin
                {
                BorderColor = Color.Transparent,
                BorderStyle = XlsxBorderStyle.None,
                FillColor = Color.Transparent,
                FontColor = Color.Black,
                FontSize = 10,
                HasBorder = false,
                IsBold = false,
                IsItalic = false,
                IsUnderline = false
            };

            var obj = expected.Clone();

            Assert.IsTrue(obj is XlsxSkin);

            var actual = (XlsxSkin)obj;

            Assert.AreEqual(expected.BorderColor.A, actual.BorderColor.A);
            Assert.AreEqual(expected.BorderColor.R, actual.BorderColor.R);
            Assert.AreEqual(expected.BorderColor.G, actual.BorderColor.G);
            Assert.AreEqual(expected.BorderColor.B, actual.BorderColor.B);
            Assert.AreEqual(expected.BorderStyle, actual.BorderStyle);
            Assert.AreEqual(expected.FillColor.A, actual.FillColor.A);
            Assert.AreEqual(expected.FillColor.R, actual.FillColor.R);
            Assert.AreEqual(expected.FillColor.G, actual.FillColor.G);
            Assert.AreEqual(expected.FillColor.B, actual.FillColor.B);
            Assert.AreEqual(expected.FontColor.A, actual.FontColor.A);
            Assert.AreEqual(expected.FontColor.R, actual.FontColor.R);
            Assert.AreEqual(expected.FontColor.G, actual.FontColor.G);
            Assert.AreEqual(expected.FontColor.B, actual.FontColor.B);
            Assert.AreEqual(expected.FontSize, actual.FontSize);
            Assert.AreEqual(expected.HasBorder, actual.HasBorder);
            Assert.AreEqual(expected.IsBold, actual.IsBold);
            Assert.AreEqual(expected.IsItalic, actual.IsItalic);
            Assert.AreEqual(expected.IsUnderline, actual.IsUnderline);
        }
    }
}
